using wnity.zframework;
using cframework.SDKUtil;
using System.Collections;
using UnityEngine;

public class Loading : MonoBehaviour
{
    private void Awake()
    {
        StartCoroutine(StartLoading());
    }

    IEnumerator StartLoading()
    {
        {
            Debug.Log($"sdk init start");
            var w = SDKMgr.sdkUtil.InitSDK().WithResult();
            yield return w;
            var initResult = (ISDKUtil.InitResult)w.Current;
            Debug.Log($"sdk init end {initResult.success} | {initResult.code}");
            if (!initResult.success)
            {
                Debug.LogError($"sdk init failed");
                yield break;
            }

            
        }


    }

    IEnumerator Login()
    {
        Debug.Log($"sdk login start");
        var w = SDKMgr.sdkUtil.Login().WithResult();
        yield return w;
        var loginResult = (ISDKUtil.LoginResult)w.Current;

        if (!loginResult.success)
        {
            Debug.LogError($"sdk login failed: {loginResult.code} | {loginResult.errMsg} | {loginResult.errno}");
            yield break;
        }
        Debug.Log($"sdk login success");
    }

    private void OnGUI()
    {
        GUI.skin.button.fontSize = 60;
        GUILayout.Button("");
        if (GUILayout.Button("login"))
        {
            StartCoroutine(Login());
        }

    }

}
